Skip to main content

Basic Usage

Basic usage includes how to start your development environment, build for production or run the storybook.

Serve

info

The serve command is exclusive to project type react-app. What are project types?

The serve command is for starting the development environment. It uses the webpack dev server to serve the application once it has finished building. It will also watch for changes and re-build once it has detected a change.

port / host

port and host to be used for the dev server. By default, plz will start the server on http://localhost:3000. If the port is already used, plz will prompt you with the option to use the next available port instead.

$ plz serve --port 3000

open-browser

By default plz will automatically open the dev environment in your default browser once the server is successfully started. If you don't want that, you can disable it via the --open-browser flag.

$ plz serve --open-browser=false

Build

The output depends on the project type. Modules and React components will be bundled optimised for releasing them as npm libraries, while React apps will be bundled into a public directory optimised for deployment. plz will default the NODE_ENV to production, unless manually specified otherwise.

$ plz build

stats

The --stats flag will run the normal build, and then automatically run webpack-bundle-analyser, giving you a nice visual representation of your bundles and which dependencies they consist of. This can be really useful when trying to improve your bundle size.

$ plz build --stats

serve

Also for react apps, you can run plz build --serve. This will build your app, but then start up a local node server to serve that build. This can be helpful if you want to test your application in production mode.

caution

Unlike the plz serve command, plz build --serve will not watch for changes and wont rebuild automatically.